#include "gtest/gtest.h"
#include <mockcpp/mokc.h>
#include <mockcpp/mockcpp.hpp>

#include <vector>
#include <iostream>

#include "topoinfo_struct.h"
#include "log.h"
#include "checker.h"
#include "virtual_topo.h"
#include "testcase_utils.h"

using namespace hccl;

class AllToAllVTest : public testing::Test {
protected:
    static void SetUpTestCase()
    {
        std::cout << "AllToAllVTest set up." << std::endl;
    }

    static void TearDownTestCase()
    {
        std::cout << "AllToAllVTest tear down." << std::endl;
    }

    virtual void SetUp()
    {
        const ::testing::TestInfo* const test_info = ::testing::UnitTest::GetInstance()->current_test_info();
        std::string caseName = "analysis_result_" + std::string(test_info->test_case_name()) + "_" + std::string(test_info->name());
        Checker::SetDumpFileName(caseName);
    }

    virtual void TearDown()
    {
        Checker::SetDumpFileName("analysis_result");
        GlobalMockObject::verify();
        // 这边每个case执行完成需要清理所有的环境变量，如果有新增的环境变量，需要在这个函数中进行清理
        ClearHcclEnv();
    }
};

void GenAllToAllVParams(u32 rankSize, u64 count, vector<u64>& sendCounts, vector<u64>& sdispls,
                        vector<u64>& recvCounts, vector<u64>& rdispls)
{
    u64 sendDisplacement = 0;
    u64 recvDisplacement = 0;
    for (u32 i = 0; i < rankSize; i++) {
        sendCounts.push_back(count);
        sdispls.push_back(sendDisplacement);
        recvCounts.push_back(count);
        rdispls.push_back(recvDisplacement);
        sendDisplacement += count;
        recvDisplacement += count;
    }
    return;
}

TEST_F(AllToAllVTest, alltoallv_test_310P3_opbase)
{
    RankTable_t ranktable;
    RankTable_For_LLT gen;
    TopoMeta topoMeta;
    gen.GenTopoMeta(topoMeta, 1, 1, 4);
    gen.GenRankTable(topoMeta, ranktable);

    TestOpParam testOpParam;
    testOpParam.opType = HcclCMDType::HCCL_CMD_ALLTOALLV;
    testOpParam.tag = "AllToAll";
    testOpParam.opMode = OPBASE;
    testOpParam.devtype = DevType::DEV_TYPE_310P3;

    testOpParam.All2AllDataDes.sendType = HcclDataType::HCCL_DATA_TYPE_INT32;
    testOpParam.All2AllDataDes.recvType = HcclDataType::HCCL_DATA_TYPE_INT32;

    GenAllToAllVParams(ranktable.rankNum, 100, testOpParam.All2AllDataDes.sendCounts, 
        testOpParam.All2AllDataDes.sdispls, testOpParam.All2AllDataDes.recvCounts, testOpParam.All2AllDataDes.rdispls);

    Checker checker;
    HcclResult ret;
    ret = checker.Check(testOpParam, ranktable, topoMeta);

    EXPECT_EQ(ret, HcclResult::HCCL_SUCCESS);
}

TEST_F(AllToAllVTest, alltoallv_test_910B_opbase_single_rank)
{
    RankTable_t ranktable;
    RankTable_For_LLT gen;
    TopoMeta topoMeta;
    gen.GenTopoMeta(topoMeta, 1, 1, 1);
    gen.GenRankTable(topoMeta, ranktable);

    TestOpParam testOpParam;
    testOpParam.opType = HcclCMDType::HCCL_CMD_ALLTOALLV;
    testOpParam.tag = "AllToAll";
    testOpParam.opMode = OPBASE;
    testOpParam.devtype = DevType::DEV_TYPE_910B;
    testOpParam.algName = "RunAlltoAllSingleExecutor";

    testOpParam.All2AllDataDes.sendType = HcclDataType::HCCL_DATA_TYPE_INT32;
    testOpParam.All2AllDataDes.recvType = HcclDataType::HCCL_DATA_TYPE_INT32;

    GenAllToAllVParams(ranktable.rankNum, 100, testOpParam.All2AllDataDes.sendCounts, 
        testOpParam.All2AllDataDes.sdispls, testOpParam.All2AllDataDes.recvCounts, testOpParam.All2AllDataDes.rdispls);

    Checker checker;
    HcclResult ret;
    ret = checker.Check(testOpParam, ranktable, topoMeta);

    EXPECT_EQ(ret, HcclResult::HCCL_SUCCESS);
}

TEST_F(AllToAllVTest, alltoallv_test_910B_opbase)
{
    RankTable_t ranktable;
    RankTable_For_LLT gen;
    TopoMeta topoMeta;
    gen.GenTopoMeta(topoMeta, 1, 1, 3);
    gen.GenRankTable(topoMeta, ranktable);

    TestOpParam testOpParam;
    testOpParam.opType = HcclCMDType::HCCL_CMD_ALLTOALLV;
    testOpParam.tag = "AllToAll";
    testOpParam.opMode = OPBASE;
    testOpParam.devtype = DevType::DEV_TYPE_910B;

    testOpParam.All2AllDataDes.sendType = HcclDataType::HCCL_DATA_TYPE_INT32;
    testOpParam.All2AllDataDes.recvType = HcclDataType::HCCL_DATA_TYPE_INT32;

    GenAllToAllVParams(ranktable.rankNum, 100, testOpParam.All2AllDataDes.sendCounts, 
        testOpParam.All2AllDataDes.sdispls, testOpParam.All2AllDataDes.recvCounts, testOpParam.All2AllDataDes.rdispls);

    Checker checker;
    HcclResult ret;
    ret = checker.Check(testOpParam, ranktable, topoMeta);

    EXPECT_EQ(ret, HcclResult::HCCL_SUCCESS);
}

TEST_F(AllToAllVTest, alltoallv_test_910B_offload)
{
    RankTable_t ranktable;
    RankTable_For_LLT gen;
    TopoMeta topoMeta;
    gen.GenTopoMeta(topoMeta, 1, 1, 3);
    gen.GenRankTable(topoMeta, ranktable);

    TestOpParam testOpParam;
    testOpParam.opType = HcclCMDType::HCCL_CMD_ALLTOALLV;
    testOpParam.tag = "AllToAll";
    testOpParam.opMode = OFFLOAD;
    testOpParam.devtype = DevType::DEV_TYPE_910B;

    testOpParam.All2AllDataDes.sendType = HcclDataType::HCCL_DATA_TYPE_INT32;
    testOpParam.All2AllDataDes.recvType = HcclDataType::HCCL_DATA_TYPE_INT32;

    GenAllToAllVParams(ranktable.rankNum, 100, testOpParam.All2AllDataDes.sendCounts, 
        testOpParam.All2AllDataDes.sdispls, testOpParam.All2AllDataDes.recvCounts, testOpParam.All2AllDataDes.rdispls);

    Checker checker;
    HcclResult ret;
    ret = checker.Check(testOpParam, ranktable, topoMeta);

    EXPECT_EQ(ret, HcclResult::HCCL_SUCCESS);
}

TEST_F(AllToAllVTest, alltoallv_test_910B_opbase_RunAlltoAllVTwoLevelPipeline)
{
    RankTable_t ranktable;
    RankTable_For_LLT gen;
    TopoMeta topoMeta;
    gen.GenTopoMeta(topoMeta, 1, 2, 8);
    gen.GenRankTable(topoMeta, ranktable);

    TestOpParam testOpParam;
    testOpParam.opType = HcclCMDType::HCCL_CMD_ALLTOALLV;
    testOpParam.tag = "AllToAll";
    testOpParam.opMode = OPBASE;
    testOpParam.devtype = DevType::DEV_TYPE_910B;
    testOpParam.algName = "RunAlltoAllVTwoLevelPipeline";

    testOpParam.All2AllDataDes.sendType = HcclDataType::HCCL_DATA_TYPE_FP16;
    testOpParam.All2AllDataDes.recvType = HcclDataType::HCCL_DATA_TYPE_FP16;

    GenAllToAllVParams(ranktable.rankNum, 100, testOpParam.All2AllDataDes.sendCounts, 
        testOpParam.All2AllDataDes.sdispls, testOpParam.All2AllDataDes.recvCounts, testOpParam.All2AllDataDes.rdispls);

    Checker checker;
    HcclResult ret;
    ret = checker.Check(testOpParam, ranktable, topoMeta);

    EXPECT_EQ(ret, HcclResult::HCCL_SUCCESS);
}

TEST_F(AllToAllVTest, alltoallv_test_910B_offload_RunAlltoAllVTwoLevelPipeline)
{
    RankTable_t ranktable;
    RankTable_For_LLT gen;
    TopoMeta topoMeta;
    gen.GenTopoMeta(topoMeta, 1, 2, 8);
    gen.GenRankTable(topoMeta, ranktable);

    TestOpParam testOpParam;
    testOpParam.opType = HcclCMDType::HCCL_CMD_ALLTOALLV;
    testOpParam.tag = "AllToAll";
    testOpParam.opMode = hccl::OFFLOAD;
    testOpParam.devtype = DevType::DEV_TYPE_910B;
    testOpParam.algName = "RunAlltoAllVTwoLevelPipeline";

    testOpParam.All2AllDataDes.sendType = HcclDataType::HCCL_DATA_TYPE_FP16;
    testOpParam.All2AllDataDes.recvType = HcclDataType::HCCL_DATA_TYPE_FP16;

    GenAllToAllVParams(ranktable.rankNum, 100, testOpParam.All2AllDataDes.sendCounts, 
        testOpParam.All2AllDataDes.sdispls, testOpParam.All2AllDataDes.recvCounts, testOpParam.All2AllDataDes.rdispls);

    Checker checker;
    HcclResult ret;
    ret = checker.Check(testOpParam, ranktable, topoMeta);

    EXPECT_EQ(ret, HcclResult::HCCL_SUCCESS);
}

TEST_F(AllToAllVTest, alltoallv_test_910B_opbase_RunAlltoAllVFullMesh)
{
    RankTable_t ranktable;
    RankTable_For_LLT gen;
    TopoMeta topoMeta;
    gen.GenTopoMeta(topoMeta, 1, 2, 8);
    gen.GenRankTable(topoMeta, ranktable);

    TestOpParam testOpParam;
    testOpParam.opType = HcclCMDType::HCCL_CMD_ALLTOALLV;
    testOpParam.tag = "AllToAll";
    testOpParam.opMode = OPBASE;
    testOpParam.devtype = DevType::DEV_TYPE_910B;
    testOpParam.algName = "RunAlltoAllVFullMesh";

    testOpParam.All2AllDataDes.sendType = HcclDataType::HCCL_DATA_TYPE_FP16;
    testOpParam.All2AllDataDes.recvType = HcclDataType::HCCL_DATA_TYPE_FP16;

    GenAllToAllVParams(ranktable.rankNum, 100, testOpParam.All2AllDataDes.sendCounts, 
        testOpParam.All2AllDataDes.sdispls, testOpParam.All2AllDataDes.recvCounts, testOpParam.All2AllDataDes.rdispls);

    Checker checker;
    HcclResult ret;
    ret = checker.Check(testOpParam, ranktable, topoMeta);

    EXPECT_EQ(ret, HcclResult::HCCL_SUCCESS);
}

TEST_F(AllToAllVTest, alltoallv_test_910B_offload_RunAlltoAllVFullMesh)
{
    RankTable_t ranktable;
    RankTable_For_LLT gen;
    TopoMeta topoMeta;
    gen.GenTopoMeta(topoMeta, 1, 2, 8);
    gen.GenRankTable(topoMeta, ranktable);

    TestOpParam testOpParam;
    testOpParam.opType = HcclCMDType::HCCL_CMD_ALLTOALLV;
    testOpParam.tag = "AllToAll";
    testOpParam.opMode = hccl::OFFLOAD;
    testOpParam.devtype = DevType::DEV_TYPE_910B;
    testOpParam.algName = "RunAlltoAllVFullMesh";

    testOpParam.All2AllDataDes.sendType = HcclDataType::HCCL_DATA_TYPE_FP16;
    testOpParam.All2AllDataDes.recvType = HcclDataType::HCCL_DATA_TYPE_FP16;

    GenAllToAllVParams(ranktable.rankNum, 100, testOpParam.All2AllDataDes.sendCounts, 
        testOpParam.All2AllDataDes.sdispls, testOpParam.All2AllDataDes.recvCounts, testOpParam.All2AllDataDes.rdispls);

    Checker checker;
    HcclResult ret;
    ret = checker.Check(testOpParam, ranktable, topoMeta);

    EXPECT_EQ(ret, HcclResult::HCCL_SUCCESS);
}

TEST_F(AllToAllVTest, alltoallv_test_910B_opbase_RunAlltoAllVStaged)
{
    RankTable_t ranktable;
    RankTable_For_LLT gen;
    TopoMeta topoMeta;
    gen.GenTopoMeta(topoMeta, 1, 2, 8);
    gen.GenRankTable(topoMeta, ranktable);

    TestOpParam testOpParam;
    testOpParam.opType = HcclCMDType::HCCL_CMD_ALLTOALLV;
    testOpParam.tag = "AllToAll";
    testOpParam.opMode = OPBASE;
    testOpParam.devtype = DevType::DEV_TYPE_910B;
    testOpParam.algName = "RunAlltoAllVStaged";

    testOpParam.All2AllDataDes.sendType = HcclDataType::HCCL_DATA_TYPE_FP16;
    testOpParam.All2AllDataDes.recvType = HcclDataType::HCCL_DATA_TYPE_FP16;

    GenAllToAllVParams(ranktable.rankNum, 100, testOpParam.All2AllDataDes.sendCounts, 
        testOpParam.All2AllDataDes.sdispls, testOpParam.All2AllDataDes.recvCounts, testOpParam.All2AllDataDes.rdispls);

    Checker checker;
    HcclResult ret;
    ret = checker.Check(testOpParam, ranktable, topoMeta);

    EXPECT_EQ(ret, HcclResult::HCCL_SUCCESS);
}

TEST_F(AllToAllVTest, alltoallv_test_910B_offload_RunAlltoAllVStaged)
{
    RankTable_t ranktable;
    RankTable_For_LLT gen;
    TopoMeta topoMeta;
    gen.GenTopoMeta(topoMeta, 1, 2, 8);
    gen.GenRankTable(topoMeta, ranktable);

    TestOpParam testOpParam;
    testOpParam.opType = HcclCMDType::HCCL_CMD_ALLTOALLV;
    testOpParam.tag = "AllToAll";
    testOpParam.opMode = hccl::OFFLOAD;
    testOpParam.devtype = DevType::DEV_TYPE_910B;
    testOpParam.algName = "RunAlltoAllVStaged";

    testOpParam.All2AllDataDes.sendType = HcclDataType::HCCL_DATA_TYPE_FP16;
    testOpParam.All2AllDataDes.recvType = HcclDataType::HCCL_DATA_TYPE_FP16;

    GenAllToAllVParams(ranktable.rankNum, 100, testOpParam.All2AllDataDes.sendCounts, 
        testOpParam.All2AllDataDes.sdispls, testOpParam.All2AllDataDes.recvCounts, testOpParam.All2AllDataDes.rdispls);

    Checker checker;
    HcclResult ret;
    ret = checker.Check(testOpParam, ranktable, topoMeta);

    EXPECT_EQ(ret, HcclResult::HCCL_SUCCESS);
}

TEST_F(AllToAllVTest, alltoallv_test_910B_opbase_RunAlltoAllDirectFullmesh)
{
    RankTable_t ranktable;
    RankTable_For_LLT gen;
    TopoMeta topoMeta;
    gen.GenTopoMeta(topoMeta, 1, 2, 8);
    gen.GenRankTable(topoMeta, ranktable);

    TestOpParam testOpParam;
    testOpParam.opType = HcclCMDType::HCCL_CMD_ALLTOALLV;
    testOpParam.tag = "AllToAll";
    testOpParam.opMode = OPBASE;
    testOpParam.devtype = DevType::DEV_TYPE_910B;
    testOpParam.algName = "RunAlltoAllDirectFullmesh";

    testOpParam.All2AllDataDes.sendType = HcclDataType::HCCL_DATA_TYPE_FP16;
    testOpParam.All2AllDataDes.recvType = HcclDataType::HCCL_DATA_TYPE_FP16;

    GenAllToAllVParams(ranktable.rankNum, 100, testOpParam.All2AllDataDes.sendCounts, 
        testOpParam.All2AllDataDes.sdispls, testOpParam.All2AllDataDes.recvCounts, testOpParam.All2AllDataDes.rdispls);

    Checker checker;
    HcclResult ret;
    ret = checker.Check(testOpParam, ranktable, topoMeta);

    EXPECT_EQ(ret, HcclResult::HCCL_SUCCESS);
}

TEST_F(AllToAllVTest, alltoallv_test_910B_offload_RunAlltoAllDirectFullmesh)
{
    RankTable_t ranktable;
    RankTable_For_LLT gen;
    TopoMeta topoMeta;
    gen.GenTopoMeta(topoMeta, 1, 2, 8);
    gen.GenRankTable(topoMeta, ranktable);

    TestOpParam testOpParam;
    testOpParam.opType = HcclCMDType::HCCL_CMD_ALLTOALLV;
    testOpParam.tag = "AllToAll";
    testOpParam.opMode = hccl::OFFLOAD;
    testOpParam.devtype = DevType::DEV_TYPE_910B;
    testOpParam.algName = "RunAlltoAllDirectFullmesh";

    testOpParam.All2AllDataDes.sendType = HcclDataType::HCCL_DATA_TYPE_FP16;
    testOpParam.All2AllDataDes.recvType = HcclDataType::HCCL_DATA_TYPE_FP16;

    GenAllToAllVParams(ranktable.rankNum, 100, testOpParam.All2AllDataDes.sendCounts, 
        testOpParam.All2AllDataDes.sdispls, testOpParam.All2AllDataDes.recvCounts, testOpParam.All2AllDataDes.rdispls);

    Checker checker;
    HcclResult ret;
    ret = checker.Check(testOpParam, ranktable, topoMeta);

    EXPECT_EQ(ret, HcclResult::HCCL_SUCCESS);
}

TEST_F(AllToAllVTest, alltoallv_test_910_93_opbase_RunAlltoAllDirectFullmesh)
{
    RankTable_t ranktable;
    RankTable_For_LLT gen;
    TopoMeta topoMeta;
    gen.GenTopoMeta(topoMeta, 1, 2, 8);
    gen.GenRankTable(topoMeta, ranktable);

    TestOpParam testOpParam;
    testOpParam.opType = HcclCMDType::HCCL_CMD_ALLTOALLV;
    testOpParam.tag = "AllToAll";
    testOpParam.opMode = OPBASE;
    testOpParam.devtype = DevType::DEV_TYPE_910_93;
    testOpParam.algName = "RunAlltoAllDirectFullmesh";

    testOpParam.All2AllDataDes.sendType = HcclDataType::HCCL_DATA_TYPE_FP16;
    testOpParam.All2AllDataDes.recvType = HcclDataType::HCCL_DATA_TYPE_FP16;

    GenAllToAllVParams(ranktable.rankNum, 100, testOpParam.All2AllDataDes.sendCounts, 
        testOpParam.All2AllDataDes.sdispls, testOpParam.All2AllDataDes.recvCounts, testOpParam.All2AllDataDes.rdispls);

    Checker checker;
    HcclResult ret;
    ret = checker.Check(testOpParam, ranktable, topoMeta);

    EXPECT_EQ(ret, HcclResult::HCCL_SUCCESS);
}

TEST_F(AllToAllVTest, alltoallv_test_910_93_offload_RunAlltoAllDirectFullmesh)
{
    RankTable_t ranktable;
    RankTable_For_LLT gen;
    TopoMeta topoMeta;
    gen.GenTopoMeta(topoMeta, 1, 2, 8);
    gen.GenRankTable(topoMeta, ranktable);

    TestOpParam testOpParam;
    testOpParam.opType = HcclCMDType::HCCL_CMD_ALLTOALLV;
    testOpParam.tag = "AllToAll";
    testOpParam.opMode = hccl::OFFLOAD;
    testOpParam.devtype = DevType::DEV_TYPE_910_93;
    testOpParam.algName = "RunAlltoAllDirectFullmesh";

    testOpParam.All2AllDataDes.sendType = HcclDataType::HCCL_DATA_TYPE_FP16;
    testOpParam.All2AllDataDes.recvType = HcclDataType::HCCL_DATA_TYPE_FP16;

    GenAllToAllVParams(ranktable.rankNum, 100, testOpParam.All2AllDataDes.sendCounts, 
        testOpParam.All2AllDataDes.sdispls, testOpParam.All2AllDataDes.recvCounts, testOpParam.All2AllDataDes.rdispls);

    Checker checker;
    HcclResult ret;
    ret = checker.Check(testOpParam, ranktable, topoMeta);

    EXPECT_EQ(ret, HcclResult::HCCL_SUCCESS);
}

TEST_F(AllToAllVTest, alltoallv_test_910_93_opbase_2superpod_RunAlltoAllDirectFullmesh)
{
    RankTable_t ranktable;
    RankTable_For_LLT gen;
    TopoMeta topoMeta;
    gen.GenTopoMeta(topoMeta, 2, 1, 9);
    gen.GenRankTable(topoMeta, ranktable);

    TestOpParam testOpParam;
    testOpParam.opType = HcclCMDType::HCCL_CMD_ALLTOALLV;
    testOpParam.tag = "AllToAll";
    testOpParam.opMode = OPBASE;
    testOpParam.devtype = DevType::DEV_TYPE_910_93;
    testOpParam.algName = "RunAlltoAllDirectFullmesh";

    testOpParam.All2AllDataDes.sendType = HcclDataType::HCCL_DATA_TYPE_FP16;
    testOpParam.All2AllDataDes.recvType = HcclDataType::HCCL_DATA_TYPE_FP16;

    GenAllToAllVParams(ranktable.rankNum, 100, testOpParam.All2AllDataDes.sendCounts, 
        testOpParam.All2AllDataDes.sdispls, testOpParam.All2AllDataDes.recvCounts, testOpParam.All2AllDataDes.rdispls);

    Checker checker;
    HcclResult ret;
    ret = checker.Check(testOpParam, ranktable, topoMeta);

    EXPECT_EQ(ret, HcclResult::HCCL_SUCCESS);
}

TEST_F(AllToAllVTest, alltoallv_test_91093_opbase_AlltoAllMeshAivFor91093Executor)
{
    MOCKER(GetExternalInputHcclAivMode).stubs().will(returnValue(true));

    RankTable_t ranktable;
    RankTable_For_LLT gen;
    TopoMeta topoMeta;
    gen.GenTopoMeta(topoMeta, 1, 2, 16);
    gen.GenRankTable(topoMeta, ranktable);

    TestOpParam testOpParam;
    testOpParam.opType = HcclCMDType::HCCL_CMD_ALLTOALLV;
    testOpParam.tag = "AllToAll";
    testOpParam.opMode = OPBASE;
    testOpParam.devtype = DevType::DEV_TYPE_910_93;
    testOpParam.aicpuUnfoldMode = true;

    testOpParam.All2AllDataDes.sendType = HcclDataType::HCCL_DATA_TYPE_FP16;
    testOpParam.All2AllDataDes.recvType = HcclDataType::HCCL_DATA_TYPE_FP16;

    GenAllToAllVParams(ranktable.rankNum, 100, testOpParam.All2AllDataDes.sendCounts, 
        testOpParam.All2AllDataDes.sdispls, testOpParam.All2AllDataDes.recvCounts, testOpParam.All2AllDataDes.rdispls);

    Checker checker;
    HcclResult ret;
    ret = checker.Check(testOpParam, ranktable, topoMeta);

    EXPECT_EQ(ret, HcclResult::HCCL_SUCCESS);
}

TEST_F(AllToAllVTest, alltoallv_test_91093_opbase_AlltoAllMeshAivFor91093Executor2)
{
    MOCKER(GetExternalInputHcclAivMode).stubs().will(returnValue(true));
    MOCKER_CPP(&AlltoAllOperator::IsSatisfyAlltoAllAivCondition).stubs().will(returnValue(true));

    RankTable_t ranktable;
    RankTable_For_LLT gen;
    TopoMeta topoMeta;
    gen.GenTopoMeta(topoMeta, 1, 2, 16);
    gen.GenRankTable(topoMeta, ranktable);

    TestOpParam testOpParam;
    testOpParam.opType = HcclCMDType::HCCL_CMD_ALLTOALLV;
    testOpParam.tag = "AllToAll";
    testOpParam.opMode = OPBASE;
    testOpParam.devtype = DevType::DEV_TYPE_910_93;
    testOpParam.aicpuUnfoldMode = true;

    testOpParam.All2AllDataDes.sendType = HcclDataType::HCCL_DATA_TYPE_FP16;
    testOpParam.All2AllDataDes.recvType = HcclDataType::HCCL_DATA_TYPE_FP16;

    GenAllToAllVParams(ranktable.rankNum, 100, testOpParam.All2AllDataDes.sendCounts, 
        testOpParam.All2AllDataDes.sdispls, testOpParam.All2AllDataDes.recvCounts, testOpParam.All2AllDataDes.rdispls);

    Checker checker;
    HcclResult ret;
    ret = checker.Check(testOpParam, ranktable, topoMeta);

    EXPECT_EQ(ret, HcclResult::HCCL_SUCCESS);
}

TEST_F(AllToAllVTest, alltoallv_test_910_93_opbase_2superpod_RunAlltoAllDirectFullmesh_postSync)
{
    RankTable_t ranktable;
    RankTable_For_LLT gen;
    TopoMeta topoMeta;
    gen.GenTopoMeta(topoMeta, 2, 1, 9);
    gen.GenRankTable(topoMeta, ranktable);

    TestOpParam testOpParam;
    testOpParam.opType = HcclCMDType::HCCL_CMD_ALLTOALLV;
    testOpParam.tag = "AllToAll";
    testOpParam.opMode = OPBASE;
    testOpParam.devtype = DevType::DEV_TYPE_910_93;
    testOpParam.algName = "RunAlltoAllDirectFullmesh";
    testOpParam.aicpuUnfoldMode = true;
    testOpParam.algOpContext.opRetryHandler.isPostSync = true;

    testOpParam.All2AllDataDes.sendType = HcclDataType::HCCL_DATA_TYPE_FP16;
    testOpParam.All2AllDataDes.recvType = HcclDataType::HCCL_DATA_TYPE_FP16;

    u64 count = 1048576;
    GenAllToAllVParams(ranktable.rankNum, count, testOpParam.All2AllDataDes.sendCounts, 
        testOpParam.All2AllDataDes.sdispls, testOpParam.All2AllDataDes.recvCounts, testOpParam.All2AllDataDes.rdispls);

    Checker checker;
    HcclResult ret;
    // postSync 会导致 checker的报错：Invalid data is copied
    ret = checker.Check(testOpParam, ranktable, topoMeta);
}
